//
//  NewPayBackTableViewCell.m
//  ChengHuiTong
//
//  Created by ypwl on 16/2/22.
//  Copyright © 2016年 张文权. All rights reserved.
//

#import "NewPayBackTableViewCell.h"

@implementation NewPayBackTableViewCell{
    
    UILabel *countLabel; //期号
    
    UILabel *timeLabel; //时间
    
    UILabel *backMoney; //回款金额
    
    UIButton *name; //项目名称
    
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        UIFont *font = [UIFont systemFontOfSize:13];
        UIColor*color=[UIColor blackColor];
        
        
        name = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/4.f, 40)];
        [name setTitleColor:kColor_AppNavColor forState:0];
        name.titleLabel.font = font;
        [name addTarget:self action:@selector(gotoDetail) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:name];
        
        
        backMoney = [[UILabel alloc]initWithFrame:CGRectMake(name.right, name.top, name.width, name.height)];
        backMoney.font = font;
        backMoney.textColor=color;
        backMoney.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:backMoney];
        

        countLabel = [[UILabel alloc]initWithFrame:CGRectMake(backMoney.right, name.top, name.width, name.height )];
        countLabel.font = font;
        countLabel.textColor=color;
        countLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:countLabel];
        
        
        timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(countLabel.right, name.top, name.width, name.height )];
        timeLabel.font = font;
        timeLabel.textColor=color;
        timeLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:timeLabel];
       

    }
    return self;
}

-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    NSMutableAttributedString *mattString = [[NSMutableAttributedString alloc]initWithString:REALSTRING(_detailModel.bid) attributes:@{NSUnderlineColorAttributeName:kColor_AppNavColor,
         NSForegroundColorAttributeName:kColor_AppNavColor,
          NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle]}];
    
    [name setAttributedTitle:mattString forState:0];
    backMoney.text=_detailModel.repay_account;
    countLabel.text=_detailModel.periods;
    
    timeLabel.text=[LGToolMethods stringFromInterval:[_detailModel.repay_time doubleValue] withFormate:@"yyyy-MM-dd"];
    
    [timeLabel setAdjustsFontSizeToFitWidth:YES];
    timeLabel.font = [UIFont systemFontOfSize:MIN(timeLabel.font.pointSize, 13)];

}

- (void)gotoDetail{
    
    if (self.goDetailVC) {
        self.goDetailVC(_detailModel);
    }
}

@end
